package inits

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"serve/internal/global/model"
)

func Init() {
	MysqlConn()
}

func MysqlConn() {
	var err error
	model.DB, err = gorm.Open(mysql.Open("root:89B158B4DAFE6F5461878D26EA49B100@tcp(14.103.158.217:3306)/7.31exam?charset=utf8&parseTime=True&loc=Local"))
	if err != nil {
		panic(err)
	}
	if err = model.DB.AutoMigrate(&model.User{}, &model.Video{}, &model.VideoClass{}, &model.VideoUpdateLog{}); err != nil {
		panic(err)
	}
	fmt.Println("mysql conn success")
}
